import java.sql.Connection;

import com.dhtmlx.connector.ConnectorServlet;
import com.dhtmlx.connector.MultitableTreeConnector;


public class tree_07_multitable extends ConnectorServlet {

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.dhtmlx.connector.ConnectorServlet#configure()
	 */
	@Override
	protected void configure() {
		Connection conn = (new DataBaseConnection()).getConnection();

		MultitableTreeConnector c = new MultitableTreeConnector(conn);
		c.set_max_level(3);
		Integer level = c.get_level();
		switch (level) {
			case 0:
				c.render_table("projects","project_id","project_name(value)","","");
				break;
			case 1:
				c.render_sql("SELECT teams.team_id, teams.team_name AS value, project_team.project_id FROM teams INNER JOIN project_team ON teams.team_id=project_team.team_id", "team_id", "team_name(value)", "", "project_id");
				break;
			case 2:
				c.render_table("developers", "developer_id", "developer_name(value)", "", "developer_team");
				break;
			case 3:
				c.render_table("phones", "phone_id", "phone(value)", "", "phone_developer");
				break;
		}
	}

}
